<?php


function InitDB(){
include "settings.php";
$link = mysql_connect($DB_HOST, $DB_USER, $DB_PASS) or die('Could not connect: ' . mysql_error());
		mysql_select_db($DB_NAME) or die('Could not select database');
		mysql_query('SET NAMES cp1251;');
return $link;
}

function CloseDB($link){
mysql_close($link);
}


function ShowUsers(){
$view='';
$link=InitDB();
$query="select UID,User, FirstName,LastName,gender,imageid from taxiusers order by UID desc";
$result=mysql_query($query);
$view="<table border='1'>";
$row=mysql_fetch_assoc($result);
$view.='<tr>';
foreach ($row as $key => $value ) $view.="<th>".$key."</th>";
$view.="</tr> \n <tr>";
foreach ($row as $key => $value ) if ($key!='imageid') $view.="<td>".$value."</td>"; else $view.="<td><img src='http://www.podvezu-nn.ru".$value."'></td>";
$view.="</tr> \n <tr>";
while ($row=mysql_fetch_assoc($result)){
$view.='<tr>';
foreach ($row as $key => $value ) if ($key!='imageid') $view.="<td>".$value."</td>"; else $view.="<td><img src='http://www.podvezu-nn.ru".$value."'></td>";
$view.='</tr>';
}
$view.='</table>';
CloseDB($link);
$view=str_replace('{content}',$view,join("",file('adminko.tpl')));
echo $view;
}


function ShowComments(){
$view='';
$link=InitDB();
$query="select * from taxicomments order by CID desc";
$result=mysql_query($query);
$view="<table border='1'>";
$row=mysql_fetch_assoc($result);
$view.='<tr>';
foreach ($row as $key => $value ) $view.="<th>".$key."</th>";
$view.='</tr><tr>';
foreach ($row as $key => $value ) $view.="<td>".$value."</td>";
$view.='</tr><tr>';
while ($row=mysql_fetch_assoc($result)){
$view.='<tr>';
foreach ($row as $key => $value ) $view.="<td>".$value."</td>";
$view.='</tr>';
}
$view.='</table>';
CloseDB($link);
$view=str_replace('{content}',$view,join("",file('adminko.tpl')));
echo $view;
}

function ShowRoutes(){
$view='';
$link=InitDB();
$query="select * from taxiroutes order by ID desc";
$result=mysql_query($query);
$view="<table border='1'>";
$row=mysql_fetch_assoc($result);
$view.='<tr>';
foreach ($row as $key => $value ) $view.="<th>".$key."</th>";
$view.='</tr><tr>';
foreach ($row as $key => $value ) $view.="<td>".$value."</td>";
$view.='</tr><tr>';
while ($row=mysql_fetch_assoc($result)){
$view.='<tr>';
foreach ($row as $key => $value ) $view.="<td>".$value."</td>";
$view.='</tr>';
}
$view.='</table>';
CloseDB($link);
$view=str_replace('{content}',$view,join("",file('adminko.tpl')));
echo $view;
}



switch ($_GET['do']){
case 'users': ShowUsers();break;
case 'routes': ShowRoutes();break;
case 'comments': ShowComments();break;
default:break;
}
exit(0);
?>